# @Time : 2021/4/9 9:41
# @Author : Fioman 
# @Phone : 13149920693
"""
设备的状态类
"""


class MainZmcStates(object):
    """
    裁切机的状态类
    """

    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False


class CamZmcStates(object):
    """
        分流机的状态类
    """

    def __init__(self):
        self.connectState = -1
        self.online = False
        self.rs = False
        self.run = False


class DeviceStates(object):
    def __init__(self):
        self.mainZmcStates = MainZmcStates()
        self.camZmcStates = CamZmcStates()
        self.cameraGroupStates = [False, False]
        self.mainAlarmInfo = ""  # 主控制器的报警信息
        self.mainAlarmInfoVisible = False
        self.mainZmcIsRs = False
        self.mainZmcIsRun = False
        self.camZmcIsRs = False
        self.camZmcIsRun = False
        self.workStopFlag = True
        self.grateHidded = False
        self.grateClear = False
        self.doorAlarm = False  # 门报警
        self.boardThicknessMax = []  # 放板厚度
        self.agvArgsData = []  # AGV参数
        self.toWhere = "收料平台1"  # 设置作业去向
        self.fullStateLV01 = "空闲"
        self.fullStateLV02 = "空闲"
        self.mainExcepInfo = ""
        self.pinFlag = True
        self.changeLv1Button = True
        self.changeLv2Button = True
        self.BMSR = True  # 下料模式人工手动或者AGV下料
        self.infoStartAGV = " "

    def pack_state_to_dict(self):
        """
        将状态信息封装为字典,好发送给前端
        :return:
        """
        res = {

            "mainZmcStates": {
                "online": self.mainZmcStates.online,
                "rs": self.mainZmcStates.rs,
                "run": self.mainZmcStates.run,
            },
            "camZmcStates": {
                "online": self.camZmcStates.online,
                "rs": self.camZmcStates.rs,
                "run": self.camZmcStates.run,
            },
            "mainAlarmInfo": self.mainAlarmInfo,
            "mainAlarmInfoVisible": self.mainAlarmInfoVisible,
            "cameraGroupStates": self.cameraGroupStates,
            "autoState": not self.workStopFlag,
            "grateHidded": self.grateHidded,  # 光栅被挡
            "doorAlarm": self.doorAlarm,
            "boardThicknessMax": self.boardThicknessMax,
            "agvArgsData": self.agvArgsData,
            "putBoardPos": self.toWhere,
            "fullStateLV01": self.fullStateLV01,
            "fullStateLV02": self.fullStateLV02,
            "mainExcepInfo": self.mainExcepInfo,
            "pinFlag": self.pinFlag,
            "changeLv1Button": self.changeLv1Button,
            "changeLv2Button": self.changeLv2Button,
            "BMSR": self.BMSR,
            "infoStartAGV": self.infoStartAGV
        }
        return res
